﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Adultorama.Ctrl;

namespace Adultorama.Gui
{
    public partial class LogInPanel : UserControl
    {
        Adultorama parent;

        public LogInPanel(Adultorama parent)
        {
            InitializeComponent();
            this.parent = parent;
        }

        private void LogInButton_Click(object sender, EventArgs e)
        {
            string userName = userNameTextBox.Text;
            string password = passwordTextBox.Text;
            LoginController liC = new LoginController();
            if (liC.Validate(userName, password))
            {
                switch(liC.type())
                {
                    case "Super":
                        {
                            this.Visible = false;
                            parent.adminMenuPanel.Visible = true;
                            userNameTextBox.Text = "";
                            passwordTextBox.Text = "";
                            break;
                        }
                    case "Limited":
                        {
                            this.Visible = false;
                            parent.userMenuPanel.Visible = true;
                            userNameTextBox.Text = "";
                            passwordTextBox.Text = "";
                            break;
                        }
                }
            }
            /*if (userName == "user" && password == "user")
            {
                this.Visible = false;
                parent.userMenuPanel.Visible = true;
                userNameTextBox.Text = "";
                passwordTextBox.Text = "";
            }
            else if (userName == "admin" && password == "admin")
            {
                this.Visible = false;
                parent.adminMenuPanel.Visible = true;
                userNameTextBox.Text = "";
                passwordTextBox.Text = "";
            }*/
            else { 
                MessageBox.Show("User Name Or Password \n"+
                                "    Is Incorrect ");
            }
        }
    }
}
